package com.xiaofei.service;


import com.xiaofei.mapper.DeptMapper;
import com.xiaofei.pojo.dept;
import com.xiaofei.service.insterface.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@Service
public class DeptServiceIml implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<dept> getAll() {
        List<dept> list = deptMapper.getAll();
        log.info(list.toString());
        return list;
    }

    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }

    @Override
    public void addDept(dept dp) {
        log.info("添加部门:{}",dp);
        //设置创建时间
        dp.setCreateTime(LocalDateTime.now());
        //修改时间
        dp.setUpdateTime(LocalDateTime.now());
        deptMapper.addDept(dp);
    }

    @Override
    public dept getById(Integer id) {
        dept d = deptMapper.getById(id);
        return d;
    }

    @Override
    public void updept(dept dp) {
        dp.setUpdateTime(LocalDateTime.now());
        deptMapper.updept(dp);
    }
}









